package at.guigu.service;

import at.guigu.dao.UserDao;
import at.guigu.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("userService")
public class UserService {
    @Autowired
    private UserDao userDao;

    // 开启事务

    @Transactional
    public void transfer(String out, String in, double money) {
        userDao.outMoney(out, money);
        int a = 1/0;
        userDao.inMoney(in, money);
    }

    public List<User> getAll() {
        List<User> users = userDao.all();
        return users;
    }
}
